import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    // 用户信息
    user: JSON.parse(window.localStorage.getItem('mobile-user') || null)
  },
  mutations: {
    // 设置用户信息
    setUser (state, user) {
      state.user = JSON.parse(user)
      // 持久化存储
      window.localStorage.setItem('mobile-user', user)
    }
  },
  actions: {},
  modules: {}
})
